#include "cnsref.h"
#include "assert.h"

CnsRef::CnsRef()
: _referenceCount(1) // when the CnsRef is created, the reference count of it is 1
{

}

CnsRef::~CnsRef()
{
}

void CnsRef::retain()
{
    assert(_referenceCount > 0);
    ++_referenceCount;
}

void CnsRef::release()
{
    if(!_referenceCount)return;
    --_referenceCount;

    if (_referenceCount == 0)
    {

        delete this;
    }
}

unsigned int CnsRef::getReferenceCount() const
{
    return _referenceCount;
}
